import http from "@/util/http";


// curl -X 'GET' \
//   'http://127.0.0.1:8000/api/v1/media/book/get_book_by_id?book_id=1' \
//   -H 'accept: application/json'
export async function getBookByIdAPI(book_id: string) {
  return await http.get(`/media/book/get_book_by_id?book_id=${book_id}`);
}

// curl -X 'POST' \
//   'http://127.0.0.1:8000/api/v1/media/book/add_book' \
//   -H 'accept: application/json' \
//   -H 'Content-Type: application/json' \
//   -d '{
//   "book_id": "",
//   "name": "string",
//   "author": "string",
//   "cover": "string",
//   "publisher": "string",
//   "publish_time": "string",
//   "isbn": "string",
//   "word_count": 0,
//   "summary": "string",
//   "urls": {
//     "douban_home": "string",
//     "dedao_home": "string",
//     "dedao_listen_home": "string"
//   }
// }'
// 添加&更新书籍
export async function addBookAPI(book:any) {
    return await http.post('/media/book/add_book', book);
}


export async function deleteBookAPI(book_id: string) {
    return await http.get(`/media/book/delete_book?book_id=${book_id}`);
}


// 分页获取书籍
// curl -X 'GET' \
//   'http://127.0.0.1:8000/api/v1/media/book/get_book_list?page=1&page_size=10' \
//   -H 'accept: application/json'
export async function getBookListAPI(page: number, page_size: number, query: string, activate?: boolean) {
    return await http.get(`/media/book/get_book_list?page=${page}&page_size=${page_size}&query=${query}&activate=${activate}`);
}
